package com.example.autumn;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
import com.example.feign.clients.fallback.config.FeignConfig;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @author Liaorun
 * 解决druid 和 sharding jdbc 的配置冲突
 */
@SpringBootApplication(exclude = {DruidDataSourceAutoConfigure.class})
@MapperScan("com.example.autumn.mapper")
@EnableFeignClients(defaultConfiguration = FeignConfig.class)
public class UCApp {

    public static void main(String[] args) {
        SpringApplication.run(UCApp.class, args);
    }


    /**
     * @return 用于消息队列发送对象时候的序列化
     */
    @Bean
    public MessageConverter messageConverter() {
        return new Jackson2JsonMessageConverter();
    }

    @Bean
    @LoadBalanced  // Ribbon的负载均衡注解
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
